The purpose of this notebook is to get you started with Jupyter notebooks. This notebook is a step-by-step guide for downloading, installing, and running Jupyter.
This notebook was originally created for a Digital Mixer session at the 2016 STELLA Unconference
The Jupyter Notebook is a browser-based, open-source tool for sharing...
interactive code,...
In [1]:
print("This is a line of code.")
visualizations,...
In [4]:
from matplotlib import pyplot as plt
import numpy as np
%matplotlib inline
plt.style.use('ggplot')
x = np.linspace(0, 2*np.pi)
plt.ylim(-1.1, 1.1)
plt.xlim(-0.1, 2*np.pi + 0.1)
plt.plot(x,[np.sin(y) for y in x], "or")
Out[4]:
and explanatory text in over 40 programming languages. Jupyter notebooks are used for everything from data exploration and computational analyses to information presentation and interactive instructional materials for mathematical, statistical, and programming concepts. They are applicable across varied fields and are popular within data sciences, scientific computing, and education.
In addition to the uses for the combined writing of code and rich text, Jupyter notebooks are easily sharable via email, cloud storage services, nbViewer or GitHub. In particular, GitHub provides storage and rendering of Jupyter notebooks in the browser for easy viewing (GitHub + Jupyter Notebooks = <3).
You can try Jupyter out in the browser first before beginning the download and setup process. Go to https://try.jupyter.org to explore interactive notebooks in Python and several other programming languages. Note that you cannot save notebooks permanently with this service. Your notebook will be deleted after 10 minutes of inactivity
Jupyter notebooks require Python to run. The easiest way to get Python and easily manage Jupyter and the data analysis/scientific packages you will use is through downloading and installing either Anaconda or Miniconda.
While both Anaconda and Miniconda install a version of Python and the conda package and environment manager, Anaconda does more by also installing over 150 of the most popular Python packages for science, math, engineering, and data analysis. The full Anaconda package requires 3 GB of available disk space.
For the sake of time and space, you can download and install Miniconda. This provides the bare minimum to get started with Jupyter. The following steps are from http://conda.pydata.org/docs/install/quick.html.
Download Miniconda here: https://github.com/blog/1995-github-jupyter-notebooks-3
Be sure to:
Mac OS X
⌘+space
to open Spotlight Search and type in 'Terminal' and press enter
cd path/to/your/file
enter
to run, following the prompts:bash Miniconda2-latest-MacOSX-x86_64.sh
Windows
Linux
cd path/to/your/file
enter
to run, following the prompts:bash Miniconda2-latest-MacOSX-x86_64.sh
To test the installation on any system enter the following command: conda list
. If correctly installed, you will see a list of installed packages.
Congratulations, you have Python and conda installed. Now you need to use conda to install Jupyter. (If you downloaded Anaconda then you already have all the libraries you need. If you followed the steps above then you will need to download the specific Python libraries you want to use, including Jupyter.)
In the terminal window run:
conda install jupyter
When prompted, type y
and press return
to proceed. It may take a little while to install.
To get started let's download pandas, a data analysis library, and matplotlib, a plotting library.
In the terminal window run:
conda install pandas matplotlib
When prompted, type y
and press return
to proceed. It may take a little while to install.
You follow the same procedure to install any other Python package, e.g.:
conda install package_name
For a full list of available conda Python packages check the official list here: Available Python packages
You now have all the dependencies to run a Jupyter notebook and do some computing. To start up a notebook server in the directory you are currently in, run the following in your terminal:
jupyter notebook
A browser window, or a tab in your opened browser, should open displaying the Notebook dashboard:
You will also see some useful information in your terminal telling you the directory in which Jupyter is running, the network address where Jupyter is running, and how to stop Jupyter, e.g.,:
$ Serving notebooks from local directory: /Users/walt/Documents/git-proj/github-public/jupyter-notebooks-intro
$ 0 active kernels
$ The Jupyter Notebook is running at: http://localhost:8888/
$ Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
Follow these steps to download an existing notebook from nbviewer and then uplaod it to your Jupyter Notebook. (The link points you to a notebook about the Jupyter Notebook user interface intended to give you practice using an interactive notebook. This notebook is stored on GitHub and rendered with nbviewer):
Upload
and navigate to the file you just downloaded and click Open
.You should now have Jupyter running on you local machine with conda and Python, two scientific computing Python packages (pandas and matplotlib), and a notebook.
These are the quick steps to running a notebook server:
cd path/to/your/folder
jupyter notebook
control+c
in the terminal and following the promptNext: To continue to an interactive notebook covering the notebook user interface, in the Notebook dashboard double-click on the notebook uploaded in the last step to open 'Jupyter - interface.ipynb'